package com.gxnzd.communityelderly.controller;

import com.gxnzd.communityelderly.commom.R;
import com.gxnzd.communityelderly.entity.Reservation;
import com.gxnzd.communityelderly.service.ReservationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ReservationController
 * Package: com.gxnzd.communityelderly.controller
 * Description:
 *  预约表信息
 * @Author 胡海峰
 * @Create 2024/11/2 14:25
 * @Version 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("/reservation")
public class ReservationController {

    @Resource
    private ReservationService reservationService;

    //预约挂号
    @PostMapping("/add")
    public R add(@RequestBody Reservation reservation){
        return reservationService.addDegister(reservation);
    }

    //根据用户id获取预约记录（医生与用户）
    @GetMapping("/list")
    public R getList(Long empId,String type,Integer page, Integer pageSize,String status){
        return reservationService.getByIdList(empId,type,page,pageSize,status);
    }

    //获取列表
    @GetMapping("/pageList")
    public R getPageList(Integer page,
                         Integer pageSize,
                         Integer userId,
                         Integer doctorId,
                         String status,
                         String startDate,
                         String endDate
                      ){
        return reservationService.getPageListInfo(page,
                pageSize,
                userId,
                doctorId,
                status,
                startDate,
                endDate);
    }

    /**
     * 将用户进行过号
     * @param id
     * @return
     */
    @GetMapping("/over/{id}")
    public R overNumber(@PathVariable Long id){
        return reservationService.overNumberID(id);
    }

    //获取预约详情
    @GetMapping("/details/{id}")
    public R getDetails(@PathVariable Long id){
        return R.success( reservationService.getById(id)) ;
    }

    //获取过去七天的预约数量
    @GetMapping("/sevenDaysNum")
    public R getSevenDaysNum(){
        return reservationService.getSevenDaysNum();
    }
}
